import { param2Obj } from '@/utils'

export default {
    getBizSelectData: config => {
        let { token , workordercategory } = param2Obj(config.url)
        workordercategory = parseInt(workordercategory)
        let children = null

        return [
            {
                label: '社区系统',
                value: 10,
                children: [
                    {
                        label: 'bbs',
                        value: 101,
                        children: [
                            { label: '3903', value: 3903,children: children }
                        ]
                    },
                    {
                        label: 'huodong',
                        value: 102,
                        children: [
                            { label: '3903', value: 3903,children: children }
                        ]
                    },
                    {
                        label: '校本资源',
                        value: 103,
                        children: [
                            { label: '3903', value: 3903,children: children }
                        ]
                    }
                ]
            },
            {
                label: '配置中心',
                value: 11,
                children: [
                    {
                        label: '配置中心',
                        value: 111,
                        children: [
                            { label: '3909', value: 3909,children: children }
                        ]
                    }
                ]
            }
        ]
    },
    getDatabase: config => {
        let { bid, sbid, port, token } = param2Obj(config.url)
        sbid = parseInt(sbid)

        if(sbid === 101){
            return [
                { 
                    label: `ewtbbs`,
                    value: `ewtbbs`
                }
            ]
        }
        if(sbid === 102){
            return [
                { 
                    label: `huodong`,
                    value: `huodong`
                }
            ]
        }
        if(sbid === 103){
            return [
                { 
                    label: `studyresource`,
                    value: `studyresource`
                }
            ]
        }
        if(sbid === 111){
            return [
                { 
                    label: `configCenter`,
                    value: `configCenter`
                }
            ]
        }
    },
    getDatatable: config => {
        const { bid, sbid, port, dbname, token } = param2Obj(config.url)
        if(dbname === 'ewtbbs'){
            return [
                {
                    label : `ewt_common_task`,
                    value : `ewt_common_task`
                },
                {
                    label : `ewt_ucenter_newp`,
                    value : `ewt_ucenter_newp`
                }
            ]
        }
        if(dbname === 'huodong'){
            return [
                {
                    label : `hd_vote`,
                    value : `hd_vote`
                },
                {
                    label : `hd_vote_log`,
                    value : `hd_vote_log`
                }
            ]
        }
        if(dbname === 'studyresource'){
            return [
                {
                    label : `sr_menu`,
                    value : `sr_menu`
                },
                {
                    label : `sr_sites`,
                    value : `sr_sites`
                }
            ]
        }
        if(dbname === 'configCenter'){
            return [
                {
                    label : `article`,
                    value : `article`
                },
                {
                    label : `cc_configclass`,
                    value : `cc_configclass`
                }
            ]
        }
    }
}